package com.exsun.gateway.jt809.kafka.gps;

import com.exsun.gateway.jt809.common.DevInfoService;
import com.exsun.gateway.jt809.data.Interface.IGpsHandle;
import com.exsun.gateway.jt809.data.PushData;
import com.exsun.gateway.jt809.handler.SendMgrHandler;
import exsun.jt808.data.config.jt809.Jt809MsgIdConfig;
import exsun.jt808.data.jt809_data.BasicVehicleInfo;
import exsun.jt808.data.jt809_data.SendBaseEntity;
import exsun.jt808.data.jt809_data.alarm.main.UpWarnMsgAdptInfo;
import exsun.jt808.data.jt809_data.alarm.main.UpWarnMsgInfoEX;
import exsun.jt808.data.upload_data.GpsData;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

public class WarnMsgInfoEx implements IGpsHandle<List<UpWarnMsgInfoEX>> {


    @Autowired
    private DevInfoService devInfoService;
    /**
     * 组包
     * @param data
     * @param sendMgrHandler
     * @return
     */
    @Override
    public  List<PushData> getPushData(List<UpWarnMsgInfoEX> data, SendMgrHandler sendMgrHandler) {
        List<PushData> pushs = new ArrayList<>();

        data.forEach(UpWarnMsgInfoEX -> {
//            byte[] body = sendMgrHandler.jt809Encode.upWarnMsgInfoEX(UpWarnMsgInfoEX);
            byte[] body = sendMgrHandler.jt809Encode.UpWarnMsgInfoEX(UpWarnMsgInfoEX,Jt809MsgIdConfig.UP_WARN_MSG_INFO_EX);
            PushData pushData = new PushData(Jt809MsgIdConfig.UP_WARN_MSG, body);
            pushs.add(pushData);
        });
        return pushs;
    }

    /**
     * 数据转换
     * 报警信息,上级平台无需应答
     * @param positionInfo
     * @param basicVehicleInfo
     * @return
     */
    public List<UpWarnMsgInfoEX> convert(GpsData positionInfo, BasicVehicleInfo basicVehicleInfo){
        return GpsConvert.alarmMsgInfoEX(positionInfo,basicVehicleInfo);
    }


}
